package com.operator

import org.apache.spark.{SparkConf, SparkContext}

object CountByKeyOperator {
  def main(args: Array[String]): Unit = {
    val sparkConf = new SparkConf().setAppName("CountByKeyOperator").setMaster("local")

    val sc = new SparkContext(sparkConf)

    val studentList = Array(("80s","yulei"),("80s","fengqili"),("80s","gaohaitao"),("80s","wangfei"),("80s","xuruyun"),("80s","xuwei"))

    val students = sc.parallelize(studentList)

    val counts = students.countByKey()
    println(counts)
  }
}
